<template>
  <div class="shop-info">
     <div class="container">
         <div class="info-title text-overflow">商户门店</div>
         <el-row :gutter="10" class="filter-box">
             <el-col :sm="8">
                  <!-- 商户名查询 -->
                <div class="filter-by-shopname">
                    <span class="text-overflow">商户名：</span>
                    <el-input class="filter-input" clearable v-model="filters.shopName" placeholder="商户名查询"></el-input>
                </div>
             </el-col>
             <el-col :sm="8">
                 <!-- 商户号查询 -->
                <div class="filter-by-shopid">
                    <span class="text-overflow">商户号：</span>
                    <el-input class="filter-input" clearable v-model="filters.shopId" placeholder="商户号查询"></el-input>
                </div>
             </el-col>
              <el-col :sm="8">
                <el-button style="width:200px" @click="queryByStatus">查询</el-button>
             </el-col>
         </el-row>
         
         <div class="shop-list" v-loading="loading">
             <table border="0" cellspacing="0" v-if="shopList.length !== 0">
                 <thead>
                     <tr>
                         <th ><div class="table-cell">商户名称</div></th>
                         <th ><div class="table-cell">商户号</div></th>
                         <th ><div class="table-cell">所在省市</div></th>
                         <th ><div class="table-cell">联系人</div></th>
                         <th ><div class="table-cell">联系电话</div></th>
                         <th ><div class="table-cell">创建时间</div></th>
                         <th ><div class="table-cell">操作</div></th>
                     </tr>
                 </thead>
                 <tbody>
                     <tr v-for="(cell,index) in shopList" :key="index">
                         <td>
                             <div class="table-cell" v-html="cell.shopName"></div>
                         </td>
                         <td>
                             <div class="table-cell" v-html="cell.shopId"></div>
                         </td>
                         <td>
                             <div class="table-cell" v-html="cell.province + cell.city + cell.adress"></div>
                         </td>
                         <td>
                             <div class="table-cell" v-html="cell.people"></div>
                         </td>
                         <td>
                             <div class="table-cell" v-html="cell.phone"></div>
                         </td>
                         <td>
                             <div class="table-cell" v-html="timestampToTime(cell.createTime)"></div>
                         </td>
                         <td>
                             <div class="table-cell">
                                 <el-button @click="getDetail(cell)">查看门店</el-button>
                             </div>
                         </td>
                     </tr>
                 </tbody>
             </table>
             <div class="no-data" v-else>
                    暂无数据
             </div>
             <div class="pages-control">
                  <el-pagination
                    @current-change="handleCurrentChange"
                    :current-page.sync="pages.currentPage"
                    :page-size="pages.page_size"
                    layout="total, prev, pager, next"
                    :total="pages.total">
                  </el-pagination>
              </div>
         </div>
         
     </div>
  </div>
</template>

<script>
export default {
  name:'shop-info',
  data () {
    return {
        loading:false,
        provinceList:[],
        cityList:[], 
        shopList:[],
        statusList:['','审核中','后台审核失败','即付审核中','即付审核失败','成功'],
        filters:{
            shopName:"",
            shopId:"",  
        },
        pages:{
          total:100,
          page_size:20,
          currentPage:1
        }
    };
  },
  components: {},
  created() {
      this.queryByStatus();
  },
  mounted() {},
  methods: {
      timestampToTime(timestamp) {
        var date = new Date(+timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
        let Y = date.getFullYear() + '-';
        let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
        let D = date.getDate() + ' ';
        let h = date.getHours() + ':';
        let m = date.getMinutes() + ':';
        let s = date.getSeconds();
        return Y+M+D+h+m+s;
      },
      queryByStatus(){
          if(this.loading){
              this.$message("正在加载！请稍候！");
              return;
          }
          let url = `user/store/findVerify`;
           let params = `?page=${this.pages.currentPage-1}&size=${this.pages.page_size}`;
            ['shopName','shopId'].forEach(element => {
                if(this.filters[element]!== null && this.filters[element]!==''){
                    params+=`&${element}=${this.filters[element]}`
                }
            });
            this.loading = true;
            this.$Http.get(url+params).then(res=>{
                this.loading = false;
                if(res.data.resp_code === "000000"){
    
                    this.shopList = res.data.result.content;
                    this.pages.total = res.data.result.totalElements;
                    if(res.data.result.content.length<=0){
                        this.$notify.info({
                            title: '消息',
                            message: "暂无门店信息！"
                        }); 
                    }
                }else{
                this.$notify.info({
                    title: '消息',
                    message: res.data.resp_message
                }); 
                } 
            }).catch(err=>{
                this.loading = false;
                this.$notify.error({
                    title: '错误',
                    message: '获取信息失败！'
                });
            })


      },
      handleCurrentChange(value){
      console.log("当前页为：",value);  
      this.queryByStatus();
      
    },

    getDetail(cell){
        console.log("查看",cell);
        this.$router.push({
            name:"subbranchDetail",
            params:{
                shopId:cell.shopId
            }
        })
    }
  }
}

</script>
<style scoped>
.shop-info{
    box-sizing: border-box;
    padding: 20px;
}
.container{
  border: 1px solid #ededed;
}
.info-title{
    height: 50px;
  line-height: 50px;
  font-size: 26px;
  color: #409eff;
  padding: 5px 20px;
  border-bottom: 1px solid #ededed;
}
.filter-input,.filter-select{
  width: 160px;
  margin-right: 10px;
}
.filter-box{
  padding: 15px;
  text-align: left;
}
.filter-by-status,.filter-by-shopname,.filter-by-shopid,.filter-by-endTime,.filter-by-start,.filter-by-phone{
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: nowrap;
}
table{
    background-color: #FFF;
    width: 100%;
    font-size: 12px;
    min-width: 900px;
}
th{
    position: relative;
    word-wrap: normal;
    text-overflow: ellipsis;
    vertical-align: middle;
    border-bottom: 1px solid #ebeef5;
    
}
thead{
    padding: 8px 0;
    color: #909399;
    background-color: #F5F7FA;
}
tr{
    padding: 8px 0;
}
tr:hover{
    background-color: #F5F7FA;
}
td{
    border: none;
    border-bottom: 1px solid #ebeef5;
}
.table-cell{
    white-space: normal;
    word-break: break-all;
    line-height: 22px;
    padding: 10px 10px;
    text-align: center;
    min-width: 100px;
    box-sizing: border-box;
}
.no-data{
    text-align: center;
    padding: 20px ;
    border: 1px solid #dbdbdb;
    color: #dbdbdb;
}

.pages-control{
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
}
.status-auth{
    display: inline-block;
    border-radius: 3px;
    padding: 5px 10px;
    background-color: #909399;
    color: #ffffff;
}
.status-1{   
    background-color: #66b1ff;
}
.status-5{
     background-color: #66b1ff;
}
</style>